<script type="text/javascript">
	function doSearchCapitalcAccount(value) {
		
	}
	
	//表格查询  
	function reloadCapitalcAccount() {
		var params = capitalcAccount_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		capitalcAccount_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		capitalcAccount_list.datagrid('unselectAll');
		capitalcAccount_list.datagrid('uncheckAll');
	}


	function addCapitalcAccount() {
		createFromWindow("新增信息", "capitalcAccount.do?editCapitalcAccount", "capitalcAccount.do?saveCapitalcAccount",
				function(data) {
					reloadCapitalcAccount();
				});
	}
	
	function deleteCapitalcAccount() {
		var rows = capitalcAccount_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('capitalcAccount.do?deleteCapitalcAccountItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadCapitalcAccount();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editCapitalcAccount() {
		var rows = capitalcAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "capitalcAccount.do?editCapitalcAccount&capitalcAccountId=" + rows[0].id,
					"capitalcAccount.do?saveCapitalcAccount", function(data) {
						reloadCapitalcAccount();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookCapitalcAccount(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = capitalcAccount_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "capitalcAccount.do?editCapitalcAccount&capitalcAccountId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	
	
	function clearCapitalcAccountSearch() {
		setGridSearchParams('capitalcAccount_list','capitalcAccountSearchForm',true,reloadCapitalcAccount);
	}
	
	//根据条件查询
	function capitalcAccountSearch() {
		setGridSearchParams('capitalcAccount_list','capitalcAccountSearchForm',false,reloadCapitalcAccount);
	}
	
	function onDblClickCapitalcAccountRow(rowIndex, rowData) {
		createFromWindow("编辑信息", "capitalcAccount.do?editCapitalcAccount&capitalcAccountId=" + rowData.id,
					"capitalcAccount.do?saveCapitalcAccount", function(data) {
						reloadCapitalcAccount();
					},true);
	}
	
	function detailCapitalcAccount() {
		var rows = capitalcAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("账户明细", "capitalcAccountRecord.do?detail&capitalcAccountId=" + rows[0].id,
					"capitalcAccount.do?saveCapitalcAccount", function(data) {
						reloadCapitalcAccount();
					},false);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function rechargeCapitalcAccount() {
		var rows = capitalcAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("账户充值", "capitalcAccountRecord.do?recharge&capitalcAccountId=" + rows[0].id,
					"capitalcAccountRecord.do?saveCapitalcAccountRecord&type=recharge", function(data) {
						reloadCapitalcAccount();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function chargebacksCapitalcAccount() {
		var rows = capitalcAccount_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("账户扣款", "capitalcAccountRecord.do?chargebacks&capitalcAccountId=" + rows[0].id,
					"capitalcAccountRecord.do?saveCapitalcAccountRecord&type=chargebacks", function(data) {
						reloadCapitalcAccount();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	function operationsRechargeCapitalcAccount(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = capitalcAccount_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("账户充值", "capitalcAccountRecord.do?recharge&capitalcAccountId=" +id,
					"capitalcAccountRecord.do?saveCapitalcAccountRecord&type=recharge", function(data) {
						reloadCapitalcAccount();
					},true);
		} else {
			showMsg('请选择充值账户记录.');
		}
	}
	
	function operationsChargebacksCapitalcAccount(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = capitalcAccount_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("账户扣款", "capitalcAccountRecord.do?chargebacks&capitalcAccountId=" +id,
					"capitalcAccountRecord.do?saveCapitalcAccountRecord&type=chargebacks", function(data) {
						reloadCapitalcAccount();
					},true);
		} else {
			showMsg('请选择充值账户记录.');
		}
	}
	
	function operationsDeleteCapitalcAccount(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('capitalcAccount.do?deleteCapitalcAccountItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadCapitalcAccount(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
</script>

<#assign operations = "[\{shiro:'ad:capitalcAccount:recharge',onClick:'operationsRechargeCapitalcAccount',src:'static/jmax/images/notes/note_edit.png',title:'充值'},
	   					\{shiro:'ad:capitalcAccount:chargebacks',onClick:'operationsChargebacksCapitalcAccount',src:'static/jmax/images/notes/note_go.png',title:'扣款'},
	   					\{shiro:'ad:capitalcAccount:delete',onClick:'operationsDeleteCapitalcAccount',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="capitalcAccount_list" toolbar="#capitalcAccountlist_search" idField="id" operations="${operations!}"
			 url="capitalcAccount.do?loadList" rownumbers="true"
			 item="com.xdtech.ad.vo.CapitalcAccountItem"/>
		
		<div id="capitalcAccountlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="capitalcAccountSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="capitalcAccountSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearCapitalcAccountSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="capitalcAccount_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="ad:capitalcAccount:add" iconCls="icon-add" onclick="addCapitalcAccount()"/>
				<@eu.linkbutton showName="明细" shiro="ad:capitalcAccount:detail" iconCls="icon-add" onclick="detailCapitalcAccount()"/>
				<@eu.linkbutton showName="充值" shiro="ad:capitalcAccount:recharge" iconCls="icon-add" onclick="rechargeCapitalcAccount()"/>
				<@eu.linkbutton showName="扣款" shiro="ad:capitalcAccount:chargebacks" iconCls="icon-add" onclick="chargebacksCapitalcAccount()"/>
				
<!-- 				<@eu.linkbutton showName="删除" shiro="ad:capitalcAccount:delete" iconCls="icon-remove" onclick="deleteCapitalcAccount()"/> -->
<!-- 				<@eu.linkbutton showName="编辑" shiro="ad:capitalcAccount:edit" iconCls="icon-edit" onclick="editCapitalcAccount()"/> -->
				<@eu.linkbutton showName="刷新" shiro="ad:capitalcAccount:refresh" iconCls="icon-reload" onclick="reloadCapitalcAccount()"/>
				
			</div>
		</div>
	</div>
</div>